import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import channel from '@/components/channel/channel'
import secondNav from '@/components/secondNav/secondNav'
import space  from '@/components/space/space'
import video from '@/components/video/video'
import login from '@/components/login/login'
Vue.use(Router)
const router =new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld
    },
    {
    	path:'/channel/:tid',
    	name:'channel',
    	component:channel,
    },
    {
    	path:'/space/',
    	name:'space',
    	component:space,
    	meta:{
    		requireAuth:true
    	},
    },
    {
    	path:'/video/av:aid',
    	name:'video',
    	component:video
    },
    {
    	path:'/login/',
    	name:'login',
    	component:login
    }
  ]
})
//全局守卫
//router.beforeEach((to,from,next)=>{
//	if(to.matched.some(record=>record.meta.requireAuth)){
//		if(localStorage.getItem("isLogin")){
//				next()
//		}else{
//				next({
//					path:'/login',
//					query:{
//						redirect:to.fullPath
//					}
//				})
//		}
//	}
//	else{
//		next()
//	}
//	console.log(to)
//	console.log(from)
////	next()
//})
export default router